home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Apple Game Sprockets / InputSprocket / Headers and Libraries / UniversalHIDModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-17  |  5.0 KB  |  165 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        UniversalHIDModule.h
  3.  
  4.      Contains:    This describes the interface a higher level part of the OS uses
  5.                 to talk with a UniversalHIDModule, and the way to implement
  6.                 a UniversalHIDModule compliant HID module.
  7.                 
  8.                 Software can use these interfaces to communicate with 
  9.                 USB HID type devices that are matched by by the system 
  10.                 extension 'USBHIDUniversalModule'.
  11.  
  12.      Version:    Technology:    USB
  13.                  Release:    InputSprocket 1.3
  14.  
  15.      Copyright:    © 1986-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  16.  
  17.      Bugs?:        Please include the the file and version information (from above) with
  18.                  the problem description.  Developers belonging to one of the Apple
  19.                  developer programs can submit bug reports to:
  20.  
  21.                      devsupport@apple.com
  22.  
  23. */
  24.  
  25. /* This interface is not USB specific, but shares many definitions with the USB spec */
  26. #ifndef __UNIVERSALHIDMODULE__
  27. #define __UNIVERSALHIDMODULE__
  28.  
  29. #ifndef __MACTYPES__
  30. #include <MacTypes.h>
  31. #endif
  32. #ifndef __USB__
  33. #include <USB.h>
  34. #endif
  35.  
  36.  
  37.  
  38. #if PRAGMA_ONCE
  39. #pragma once
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT
  47. #pragma import on
  48. #endif
  49.  
  50. #if PRAGMA_STRUCT_ALIGN
  51.     #pragma options align=mac68k
  52. #elif PRAGMA_STRUCT_PACKPUSH
  53.     #pragma pack(push, 2)
  54. #elif PRAGMA_STRUCT_PACK
  55.     #pragma pack(2)
  56. #endif
  57.  
  58. typedef UInt32                             UHIDModuleConnectionID;
  59. /* FunctionPtr to be called when inturrupt occurs*/
  60. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  61. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  62. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  63. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  64. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  65. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  66. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  67. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  68.  
  69. enum {
  70.     kCurrentDispatchTableVersion = 5,
  71.     kOldestCompatableDispatchTableVersion = 5
  72. };
  73.  
  74. /*
  75.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  76.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  77.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  78.           (the oldest built client using this API that this UHIDModule will work with)
  79.    venderID is who wrote this UniversalHIDModule (hi word of 0 and USB venderID is valid)
  80. */
  81.  
  82. struct UHIDModuleDispatchTableStruct {
  83.     UInt16                             dispatchTableCurrentVersion;
  84.     UInt16                             dispatchTableOldestVersion;
  85.     UInt32                             venderID;
  86.     UInt32                             venderSpecific;
  87.     UInt32                             reserved;
  88.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  89.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  90.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  91.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  92.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  93.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  94. };
  95. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  96.  
  97. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  98. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  99. /* the prototypes for the actual functions in the UHIDModule follow*/
  100. EXTERN_API_C( OSStatus )
  101. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  102.                                  void *                    outInfo);
  103.  
  104. EXTERN_API_C( OSStatus )
  105. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  106.                                  UInt32                 inDescriptorIndex,
  107.                                  UInt32 *                ioBufferSize,
  108.                                  void *                    outBuffer);
  109.  
  110. /* Claim and release are a way to insure that only one client is connected*/
  111. EXTERN_API_C( OSStatus )
  112. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  113.                                  UInt32                 reserved);
  114.  
  115. EXTERN_API_C( OSStatus )
  116. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  117.  
  118. EXTERN_API_C( OSStatus )
  119. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  120.                                  UHIDInterruptProcPtr     inInterruptProc,
  121.                                  UInt32                 inRefcon);
  122.  
  123. EXTERN_API_C( OSStatus )
  124. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  125.                                  UInt32                 inControlSelector,
  126.                                  void *                    ioControlData);
  127.  
  128. /* these are the constants to be passed to UHIDControlDevice*/
  129.  
  130. enum {
  131.     kUHIDRemoveInterruptHandle    = 0,
  132.     kUHIDVenderSpecificControlStart = 0x00010000
  133. };
  134.  
  135. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  136.  
  137. enum {
  138.     kUHIDGetVenderID            = 0,
  139.     kUHIDGetProductID            = 1,
  140.     kUHIDGetMaxPacketSize        = 2,
  141.     kUHIDVenderSpecificGetInfoStart = 0x00010000
  142. };
  143.  
  144.  
  145. #if PRAGMA_STRUCT_ALIGN
  146.     #pragma options align=reset
  147. #elif PRAGMA_STRUCT_PACKPUSH
  148.     #pragma pack(pop)
  149. #elif PRAGMA_STRUCT_PACK
  150.     #pragma pack()
  151. #endif
  152.  
  153. #ifdef PRAGMA_IMPORT_OFF
  154. #pragma import off
  155. #elif PRAGMA_IMPORT
  156. #pragma import reset
  157. #endif
  158.  
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162.  
  163. #endif /* __UNIVERSALHIDMODULE__ */
  164.  
  165.